import { createRouter, createWebHistory } from "vue-router";

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: "/",
      redirect: "/home",
    },
    {
      path: "/home",
      name: "home",
      component: () => import("../views/home/index.vue"),
      meta: { title: "首页" },
    },
    {
      path: "/clue",
      name: "clue",
      redirect: "/clue/list",
      meta: { title: "线索管理" },
      children: [
        {
          path: "list",
          name: "clue-list",
          component: () => import("../views/clue/list.vue"),
          meta: { title: "线索列表" },
        },
        {
          path: "pool",
          name: "clue-pool",
          component: () => import("../views/clue/pool.vue"),
          meta: { title: "线索池" },
        },
      ],
    },
    {
      path: "/business",
      name: "business",
      redirect: "/business/list",
      meta: { title: "商机管理" },
      children: [
        {
          path: "list",
          name: "business-list",
          component: () => import("../views/business/list.vue"),
          meta: { title: "商机列表" },
        },
        {
          path: "pool",
          name: "business-pool",
          component: () => import("../views/business/pool.vue"),
          meta: { title: "公海池" },
        },
      ],
    },
    {
      path: "/customer",
      name: "customer",
      component: () => import("../views/customer/index.vue"),
      meta: { title: "客户管理" },
    },
    {
      path: "/resource",
      name: "resource",
      redirect: "/resource/course",
      meta: { title: "资源管理" },
      children: [
        {
          path: "course",
          name: "resource-course",
          component: () => import("../views/resource/course.vue"),
          meta: { title: "课程管理" },
        },
        {
          path: "activity",
          name: "resource-activity",
          component: () => import("../views/resource/activity.vue"),
          meta: { title: "活动管理" },
        },
      ],
    },
    {
      path: "/system",
      name: "system",
      redirect: "/system/dept",
      meta: { title: "系统管理" },
      children: [
        {
          path: "dept",
          name: "system-dept",
          component: () => import("../views/system/dept.vue"),
          meta: { title: "部门管理" },
        },
        {
          path: "role",
          name: "system-role",
          component: () => import("../views/system/role.vue"),
          meta: { title: "角色管理" },
        },
        {
          path: "user",
          name: "system-user",
          component: () => import("../views/system/user.vue"),
          meta: { title: "用户管理" },
        },
        {
          path: "log",
          name: "system-log",
          component: () => import("../views/system/log.vue"),
          meta: { title: "系统日志" },
        },
      ],
    },
  ],
});

export default router;
